$(function () {
    从原网页获取数据
        // 获取每个li的内容 共14个
        ; (function () {
            var $li = $(".banner-itemleft li")
            var n = $li.length
            var sql = "";
            for (var i = 0; i < n; i++) {
                var _text = $li.eq(i).find("a").text();
                sql += "insert into t_bannerleft_text (text,text_id) values ('" + _text + "'," + i + ");"
            }
            console.log(sql);
        })()

    $("#menuData>ul>li").eq(0).children(".menu_floor").eq(0).children(".menu_floor_a").children("a").eq(0).text();

    // 获取ban_lf_item里的title内容
    ; (function () {
        var sq = "";
        for (var j = 0; j < $("#menuData>ul>li").length; j++) {
            var $mf = $("#menuData>ul>li").eq(j).children(".menu_floor");
            var _j = j.toString();
            for (var i = 0; i < $mf.length; i++) {
                var _i = i.toString();
                var _text = $mf.eq(i).children("span").children("a").text();
                sq += "insert into t_ban_lf_item_title (title,title_id) values ('" + _text + "','" + _j + _i + "');";
            }
        }
        console.log(sq);
    })

        // 获取ban_lf_item下的每个title里面的每一个具体内容
        ; (function () {
            $("#menuData>ul>li").eq(j).children(".menu_floor").eq(i).children(".menu_floor_a").children("a").eq(0).text();

            var sqlct = "";
            for (var j = 0; j < $("#menuData>ul>li").length; j++) {
                var $mflor = $("#menuData>ul>li").eq(j).children(".menu_floor");
                var _j = j.toString();
                for (var i = 0; i < $mflor.length; i++) {
                    var $mfa = $mflor.eq(i).children(".menu_floor_a");
                    var _i = i.toString();
                    for (var k = 0; k < $mfa.children("a").length; k++) {
                        var _k = k.toString();
                        var _text = $mfa.children("a").eq(k).text();
                        var _href = $mfa.children("a").eq(k).attr("href");
                        sqlct += "insert into t_item_title_child (href,cont, child_id) values ('" + _href + "','" + _text + "','" + _j + _i + _k + "');";
                    }
                }
            }
            console.log(sqlct);
        })()


    // 获取每个li下item对应的图片
    $("#menuData>ul>li").eq(0).children(".menu_right_img").children("a").eq(0).children().attr("src");
    var $li = $("#menuData>ul>li");
    console.log($li)
    var sq = "";
    // for (var i = 0; i < $li.length; i++) {
    //     var $a = $li.eq(i).children(".menu_right_img").children("a");
    //     for (var j = 0; j < $a.length; i++) {
    //         var _src = $a.eq(j).children().attr("src");
    //         sq += "insert into t_text_id (img_src, text_id) values ('" + _src + "'," + (i + 1) + ");";
    //     }
    // }
    // console.log(sq);

    var arr = [];
    $('#menuData').find('.menu_right_img').each(function () {
        var opts = {};
        $(this).find('a').each(function (i) {
            opts["href" + i] = $(this).attr('href');
            opts["src" + i] = $(this).children("img").attr('src');
        })
        arr.push(opts);
    });
    var sq0 = "";
    for (var m = 0; m < arr.length; m++) {
        var _m = m.toString() + "0";
        var _n = m.toString() + "1";
        sq0 += "insert into t_title_child_img (a_href,img_src,img_id) values ('" + arr[m].href0 + "','" + arr[m].src0 + "','" + _m + "');insert into t_title_child_img (a_href,img_src,img_id) values ('" + arr[m].href1 + "','" + arr[m].src1 + "','" + _n + "');";
    }
    console.log(sq0);

     // var arr1 = [];
    var _sq = "";
    $(".banner-itemleft li span").each(function (i) {
        var _i = i.toString();
        $(this).children("a").each(function (j) {
            var _j = j.toString();
            var _text = $(this).text();
            var _href = $(this).attr("href");
            _sq += "insert into t_bannerleft (text,a_href,cont_id) values ('" + _text + "','" + _href + "','" + _i + _j + "');";
        })
    })
    console.log(_sq);

    // 大轮播图右侧数据

    console.log($(".life_i1").html())

    // 超值团右侧数据
    var datas = [];
    // var data_arr = {};.
    $("#new_czt_ul>li").each(function (i) {
        var _src = $(this).children(".new_czt_show").find("img").attr("src");
        var _text = $(this).children(".new_czt_show").children(".new_czt_name").children().text();
        var _price = $(this).children(".new_czt_show").children(".new_czt_money").find(".money").text();
        var _rprice = $(this).children(".new_czt_show").children(".new_czt_money").find(".price").text();
        var _ticket = $(this).children(".new_czt_show").children(".ticket").text();
        var data_arr = {};
        data_arr.d_src = _src;
        data_arr.d_text = _text;
        data_arr.d_price = _price;
        data_arr.d_rprice = _rprice;
        data_arr.d_ticket = _ticket;
        datas.push(data_arr);
    })
    console.log(datas);
    // datas[i].d_src
    var sql = "";
    for (var i = 0; i < datas.length; i++) {
        sql += `insert into t_supergroup (d_src,d_text,d_price,d_rprice,d_ticket) values ('${datas[i].d_src}','${datas[i].d_text}','${datas[i].d_price}','${datas[i].d_rprice}','${datas[i].d_ticket}');`;
    }
    console.log(sql);

    // 相见恨晚
    var datas = [];
    $(".new_tm_r>li").each(function () {
        var data = {};
        var _src = $(this).find("img").attr("src");
        data.src = _src;
        datas.push(data);
    })
    console.log(datas);
    var sql = "";
    for (var i = 0; i < datas.length; i++) {
        sql += `insert into t_f_c_imgs (img_src) values ('${datas[i].src}');`;
    }
    console.log(sql);

    // 猜你喜欢数据的获取
    var w_datas = [];
    $(".alsolike>.like_class").each(function () {
        var datas = [];
        $(this).children("li").each(function () {
            var _src = $(this).find(".pro-img").find("img").attr("src");
            var _text = $(this).find(".pro-name").children("a").text();
            var _price = $(this).find(".pro-money").find("span").text();
            var data = {};
            data.d_src = _src;
            data.d_text = _text;
            data.d_price = _price;
            datas.push(data);
        })
        w_datas.push(datas);
    })
    console.log(w_datas);
    var sql = "";
    for (var i = 0; i < w_datas.length; i++) {
        for (var j = 0; j < w_datas[i].length; j++) {
            sql += `insert into t_guesslike (img_src,text,price) values ('${w_datas[i][j].d_src}','${w_datas[i][j].d_text}','${w_datas[i][j].d_price}');`;
        }
    }
    console.log(sql);
})